<template>

	<div>
		<div style="margin-top: 15px;">
			<el-input placeholder="请输入病历号" v-model="tableData.casenumber" class="input-with-select" clearable>
				<el-button slot="append" icon="el-icon-search" @click="selectById()"></el-button>
			</el-input>
			<el-input placeholder="请输入姓名" v-model="tableData.realname" class="input-with-select"
				style="margin-top:15px;" clearable>
				<el-button slot="append" icon="el-icon-search" @click="selectById()"></el-button>
			</el-input>
		</div>
		
		

		<el-table :data="tableData" stripe highlight-current-row style="width: 110%; margin-top: 15px;">
			<el-table-column type="expand">
				<template slot-scope="props">
					<el-descriptions class="margin-top" :column="3" :size="size" border>
					    <el-descriptions-item>
					      <template slot="label">
					        <i class="el-icon-user"></i>
					        身份证号
					      </template>
					      {{ props.row.idnumber }}
					    </el-descriptions-item>
					    <el-descriptions-item>
					      <template slot="label">
					        <i class="el-icon-office-building"></i>
					        家庭住址
					      </template>
					      {{ props.row.homeaddress }}
					    </el-descriptions-item>
					    <el-descriptions-item>
					      <template slot="label">
					        <i class="el-icon-location-outline"></i>
					        本次挂号级别
					      </template>
						  <el-tag size="medium" type="primary" v-if="props.row.registleid===1">专家号</el-tag>
						  <el-tag size="medium" type="success" v-else-if="props.row.registleid===2">普通号</el-tag>
					    </el-descriptions-item>
					    <el-descriptions-item>
					      <template slot="label">
					        <i class="el-icon-tickets"></i>
					        出生日期
					      </template>
					      {{ props.row.birthdate }}
					    </el-descriptions-item>
					    <el-descriptions-item>
					      <template slot="label">
					        <i class="el-icon-price-tag"></i>
					        本次挂号科室ID
					      </template>
					     <el-tag size="small" type="danger">{{ props.row.deptid }}</el-tag>
					    </el-descriptions-item>
					  </el-descriptions>
				</template>
			</el-table-column>

			<el-table-column prop="id" label="id" sortable fixed=true>
			</el-table-column>
			<el-table-column prop="casenumber" label="病历号" sortable>
			</el-table-column>
			<el-table-column prop="realname" label="姓名" sortable>
			</el-table-column>
			<el-table-column prop="gender" label="性别" sortable>
				<template slot-scope="scope">
					<el-tag size="medium" type="primary" v-if="scope.row.gender===71 ">男</el-tag>
					<el-tag size="medium" type="success" v-else-if="scope.row.gender===72">女</el-tag>
					<el-tag size="medium" type="info" v-else>其他</el-tag>
				</template>
			</el-table-column>
			<el-table-column prop="age" label="年龄" sortable>
			</el-table-column>
			<el-table-column prop="agetype" label="年龄类型" sortable fixed=true>
			</el-table-column>
			<el-table-column prop="visitdate" label="本次查诊日期" sortable>
			</el-table-column>
			<el-table-column prop="noon" label="午别" sortable>
				<template slot-scope="scope">
					<el-tag size="medium" type="primary" v-if="scope.row.noon==='上午'">上午</el-tag>
					<el-tag size="medium" type="success" v-else-if="scope.row.noon==='下午'">下午</el-tag>
					<el-tag size="medium" type="info" v-else>其他</el-tag>
				</template>
			</el-table-column>
			<el-table-column prop="settleid" label="结算类别ID" sortable>
				<template slot-scope="scope">
					<el-tag size="medium" type="primary" v-if="scope.row.settleid===1">自费</el-tag>
					<el-tag size="medium" type="success" v-else-if="scope.row.settleid===2">市医保</el-tag>
					<el-tag size="medium" type="info" v-else>其他</el-tag>
				</template>
			</el-table-column>
			<el-table-column prop="isbook" label="病历本要否" sortable>
			</el-table-column>
			<el-table-column prop="registtime" label="挂号时间" sortable>
			</el-table-column>
			<el-table-column prop="registerid" label="挂号员ID" sortable>
			</el-table-column>
			<el-table-column prop="visitstate" label="本次看诊状态" sortable>
				<template slot-scope="scope">
					<el-tag size="medium" type="primary" v-if="scope.row.visitstate===1">已挂号</el-tag>
					<el-tag size="medium" type="success" v-else-if="scope.row.visitstate===2">医生接诊</el-tag>
					<el-tag size="medium" type="warning" v-else-if="scope.row.visitstate===3">诊毕</el-tag>
					<el-tag size="medium" type="danger" v-else-if="scope.row.visitstate===4">已退号</el-tag>
					<el-tag size="medium" type="info" v-else>其他</el-tag>
				</template>
			</el-table-column>
			<el-table-column label="操作">
				<template slot-scope="scope">
					<el-button type="primary" size="small" @click="visitstateswitch(scope.row.id)"
						icon="el-icon-circle-check">诊毕</el-button>
				</template>
			</el-table-column>
		</el-table>
	</div>
</template>

<script>
	export default {
		name: "TreatmentOver",
		data() {
			return {
				tableData: {
					id: '',
					casenumber: '',
					realname: '',
					gender: '',
					idnumber: '',
					birtdate: '',
					age: '',
					agetype: '',
					homeaddress: '',
					visitdate: '',
					noon: '',
					deptid: '',
					userid: '',
					registleid: '',
					settleid: '',
					isbook: '',
					registtime: '',
					registerid: '',
					visitstate: ''
				}
			}
		},
		created() {
			let url = '/register/selectBycasenumber'
			this.$axios.post(url)
				.then((resp) => {
					this.tableData = resp.data;
					console.log(this.tableData)
				})
		},
		methods: {
			selectById() {
				let url = '/register/selectBycasenumber'
				let param = this.$qs.stringify(this.tableData);
				this.$axios.post(url, param)
					.then((resp) => {
						this.tableData = resp.data;
						console.log(this.tableData)
					})
			},
			visitstateswitch(id) {
				console.log(id);

				let url = '/register/updatevisitstate';
				let param = {};
				param.id = id;
				param = this.$qs.stringify(param);
				this.$axios.post(url, param)
					.then((resp) => {
						let i = resp.data;
						if (i > 0) {
							this.$notify({
								title: '诊毕成功',
								message: '成功诊毕此患者',
								type: 'success'
							})
						} else {
							this.msg = '修改失败，请处理'
						}
					})
					.catch((err) => {
						console.log('error=', err);
					})
			}
		},
	}
</script>

<style scoped>

</style>
